/*
 * Singularity Engine
 * Copyright (C) 2010 Vyacheslav Vorobyov, All rights reserved.
 * See LICENSE for full license information.
 */
package org.singularity.lang.model;

import java.util.ArrayList;
import java.util.List;

/**
 * @author vjache
 *
 */
public class RHS {
	
	public abstract class Action
	{public abstract void toString(StringBuilder sb, String string);}
	
	public abstract class TupleAction extends Action
	{
		private final TuplePattern _tuple;

		public TupleAction(TuplePattern tuple) {_tuple = tuple;}
		public TuplePattern getTuple() 
		{return _tuple;}
	}
	
	public class AssertTuple extends TupleAction
	{
		public AssertTuple(TuplePattern tuple) 
		{super(tuple);}

		@Override
		public void toString(StringBuilder sb, String shift) {
			sb.append(shift).append("ASSERT").append(StringUtil.NL);
			getTuple().toString(sb, shift+StringUtil.TAB);
		}	
	}
	
	public class RetractTuple extends TupleAction
	{
		public RetractTuple(TuplePattern tuple) 
		{super(tuple);}

		@Override
		public void toString(StringBuilder sb, String shift) {
			sb.append(shift).append("RETRACT").append(StringUtil.NL);
			getTuple().toString(sb, shift+StringUtil.TAB);
		}	
	}

	private final List<Action> _actions = new ArrayList<Action>(10); 
	/**
	 * 
	 */
	public RHS() {}
	/**
	 * @return the actions
	 */
	public List<Action> getActions() 
	{return _actions;}

	public static void main(String[] args) {
		RHS rhs = new RHS();
		rhs.new AssertTuple(null);
	}
	public void toString(StringBuilder sb, String shift) {
		sb.append(shift).append("RHS").append(StringUtil.NL);
		for(Action act:_actions)
		{
			act.toString(sb,shift+StringUtil.TAB);
			sb.append(StringUtil.NL);
		}
	}
}
